package com.control;

import com.pojo.Work;
import com.service.impl.WorkServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/work")
@CrossOrigin(allowCredentials = "true")
public class WorkControl {

    final private WorkServiceImpl workService;
    @Autowired
    public WorkControl(WorkServiceImpl workService){
        this.workService = workService;
    }

    @RequestMapping("/add_work")
    public String addWork(String courseId, String name){
        return workService.createWork(courseId, name);
    }

    @RequestMapping("/del_work")
    public String delWork(String id, String courseId){
        return workService.deleteWork(id, courseId);
    }

    @RequestMapping("/sel_work_by_course_id")
    public List<Work> findWorkByCourseId(String courseId){
        return workService.findWorkByCourseId(courseId);
    }
}
